package com.applet.mallappletbackstage.service.impl;

import com.applet.mallappletbackstage.entity.Nation;
import com.applet.mallappletbackstage.mapper.NationMapper;
import com.applet.mallappletbackstage.service.NationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.nio.channels.NonWritableChannelException;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author X
 * @since 2020-08-13
 */
@Service
public class NationServiceImpl extends ServiceImpl<NationMapper, Nation> implements NationService {

    /***
     * 保存民族
     * @param nation
     * @return
     */
    @Override
    public int nationService(String nation) {
        Nation nationName = new Nation();
        nationName.setNation(nation);
        return baseMapper.insert(nationName);
    }

    /***
     * 通过id获取民族
     * @param id
     * @return
     */
    @Override
    public Nation getNation(Integer id) {
        QueryWrapper<Nation> nationQueryWrapper = new QueryWrapper<>();
        nationQueryWrapper.eq("id",id);
        Nation nation = baseMapper.selectOne(nationQueryWrapper);
        return nation;
    }
}
